package com.loopy.session;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;

@WebServlet(name = "ReadSessionServlet", value = "/readSession")
public class ReadSessionServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doPost(request, response);
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        System.out.println("ReadServlet被调用");
        HttpSession session = request.getSession();
        Object email = session.getAttribute("email");
        if(email!=null){
            System.out.println("session属性Email="+(String)email);
        }else{
            System.out.println("属性为空");
        }
    }
}
